<#include "/common/h-ui-base-css.html">
<#include "/common/h-ui-base-js.html">
<#include "/common/validation-js.html">
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-column-add">
        <table class="table table-border table-bordered table-bg">
            <tbody>
                <tr class="text-c">
                    <th>表格名称</th>
                    <td>
                        <div class="formControls">
                            <input type="text" class="input-text" value="${entity.tableName!}" placeholder="" id="tableName" name="tableName">
                        </div>
                    </td>
                </tr>
                <tr class="text-c">
                    <th>实体名称</th>
                    <td>
                        <div class="formControls">
                            <span class="select-box">
                                <select class="select" name="className" id="className" size="1">
                                    <option value="">---请选择实体名称---</option>
                                    <#if list??>
                                        <#list list as list>
                                            <option value="${list}" <#if entity.className??><#if list==entity.className>selected</#if></#if>>${list}</option>
                                        </#list>
                                    </#if>
                                </select>
                            </span>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">
    $(function(){

        var id = ${entity.id!-1};

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $("#form-column-add").validate({
            rules:{
                tableName:{
                    required:true,
                    minlength:2,
                    maxlength:16
                },
                className:{
                    required:true,
                    minlength:1,
                    maxlength:16
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "/column-save/"+id ,
                    data :$("form-column-add").serialize(),
                    async:false,
                    success: function(data){
                        layer.msg('添加成功!',{icon:1,time:1000});
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg('error!',{icon:1,time:1000});
                    }
                });
                var index = parent.layer.getFrameIndex(window.name);
                parent.$('#column_table').datagrid('reload');
                parent.layer.close(index);
            }
        });
    });
</script>

<!--/请在上方写此页面业务相关的脚本-->
</body>
